﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using SharedGenomics.Workbench.Core;

namespace ROWorkbench
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            var ptrSize = System.IntPtr.Size;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            
            Application.Run(new MainForm());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            var action = MessageBox.Show(String.Format("An unhandled exception occured in ROWorkbench:{0}{1}{0}{2}", Environment.NewLine, e.Exception.Message, e.Exception.StackTrace), "Error in ROWorkbench", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
            if (action == DialogResult.Abort)
                Application.Exit();
        }
    }
}
